package com.ml.refactor;

public class Rental {

	private Movie _movie;
	private Integer _daysRented;
	
	public Rental(Movie movie,Integer daysRented) {
		_movie = movie;
		_daysRented = daysRented;
	}
	
	public Integer getDaysRented() {
		return _daysRented;
	}
	
	public Movie getMovie() {
		return _movie;
	}
	
	/**
	 * 计算租凭费用
	 * @return result 费用
	 */
	public double getCharge() {
		double result = 0;
		switch (getMovie().getPriceCode()) {
		case Movie.REGULER:
			result +=2;
			if(getDaysRented()>2)
				result +=(getDaysRented()-2)*1.5;
			break;
		case Movie.NEW_RELEASE:
			result += (getDaysRented())*3;
			break;
		case Movie.CHILDRENS:
			result +=1.5;
			if(getDaysRented()>3)
				result +=(getDaysRented()-3)*1.5;
			break;
	}
		return result;
	}
	
	public int getFrequenRenterPoints() {
		
		if((getMovie().getPriceCode()==Movie.NEW_RELEASE)&&getDaysRented()>1)
			return 2;
		
		return 1;
		
	}
	
}
